package com.hclc.entity.model.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * @ClassName UpdateStatusEnum
 * @Author: yurj
 * @Mail：1638234804@qq.com
 * @Date: Create in 15:32 2020/8/13
 * @version: 1.0
 */
public enum UpdateStatusEnum implements IEnum<Integer> {


    YES(1, "是"),


    NO(0, "否");



    @JsonValue
    @EnumValue
    private final int code;


    private final String desc;
    UpdateStatusEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }
    @Override
    public Integer getValue() {
        return code;
    }
    public String getDesc(){return desc;}
    public static UpdateStatusEnum find( String desc ) throws IllegalArgumentException{
        for (UpdateStatusEnum model : UpdateStatusEnum.values()) {
            if (model.getDesc().equals(desc)) {
                return model;
            }
        }
        throw new IllegalArgumentException();
    }
    @JsonCreator
    public static UpdateStatusEnum find( int code ) throws IllegalArgumentException{
        for (UpdateStatusEnum model : UpdateStatusEnum.values()) {
            if (model.getValue() == code) {
                return model;
            }
        }
        throw new IllegalArgumentException();
    }
}
